Skip to content

Add GROQ language support#7914

Open
rexxars wants to merge 1 commit intogithub-linguist:mainfrom
sanity-io:feat/add-groq-language
Open

Add GROQ language support#7914
rexxars wants to merge 1 commit intogithub-linguist:mainfrom
sanity-io:feat/add-groq-language

Conversation

@rexxars
Copy link
Copy Markdown

@rexxars rexxars commented Apr 13, 2026

Add GROQ (Graph-Relational Object Queries) as a recognized data language with syntax highlighting for .groq files, JS/TS template literal injection, and markdown code block injection.

  • Grammar source: sanity-io/groq-syntax (textmate-groq) (MIT licensed)
  • Scopes: source.groq, groq-injection.js, groq-injection.markdown
  • Samples: blog query, product filter, site navigation

Description

GROQ is an open query language for JSON-like data, created by Sanity.io and published under the OWFa 1.0 license since 2019. It is purpose-built for querying and transforming content in document stores, with first-class support for references, projections, and filtering.

GROQ is widely used across the Sanity ecosystem, which includes companies like Nike, Figma, Cloudflare, Spotify, Shopify, and Riot Games. The groq npm package sees 800k+ weekly downloads (24M+ annually).

While .groq files represent one surface for the language, the majority of GROQ is written as tagged template literals in JavaScript/TypeScript (groq`*[_type == "post"]`) and in markdown code blocks (```groq). The grammar source (sanity-io/groq-syntax) provides injection grammars for both of these, following the same pattern as GraphQL in Linguist (inline.graphql, inline.graphql.markdown.codeblock via graphql/graphiql).

A pull request to add an ace mode is open, but is yet to be reviewed/accepted - so using text for now until it has landed.

Usage evidence

Signal Count Search
groq template literals in TS 3,400+ files search
groq template literals in JS 2,100+ files search
```groq markdown blocks 630+ files search
import groq in JS/TS 2,600+ files search
.groq files (excl. forks) 200+ files / 40+ repos search

The .groq extension meets the 200-file threshold for extensions that typically occur once per repository (like Makefile). The results show broad distribution across independent users and organizations - not concentrated in Sanity's own repos.

The broader surface (5,500+ template literal files, 630+ markdown code blocks) demonstrates that the community already treats GROQ as a distinct language deserving syntax highlighting.

VS Code extension

The Sanity VS Code extension has 50,000+ installs and has provided GROQ syntax highlighting since 2018. The grammar was recently extracted to a dedicated repo (sanity-io/groq-syntax) to support multiple editors and Linguist integration.

Checklist:

  • I am adding a new language.
    • The extension of the new language is used in hundreds of repositories on GitHub.com.
    • I have included a real-world usage sample for all extensions added in this PR:
      • Sample source(s):
        • Samples written for this PR, representative of common GROQ patterns (content queries with references, faceted filtering with parameters, conditional projections)
      • Sample license(s): MIT (same as Linguist)
    • I have included a syntax highlighting grammar: https://github.com/sanity-io/groq-syntax
    • I have added a color
      • Hex value: #fa84ff
      • Rationale: Magenta from GROQ's brand palette.
    • I have updated the heuristics to distinguish my language from others using the same extension.
      Not needed - .groq is not used by any other language.

Add GROQ (Graph-Relational Object Queries) as a recognized data language
with syntax highlighting for .groq files, JS/TS template literal injection,
and markdown code block injection.

- Grammar source: sanity-io/groq-syntax (MIT licensed)
- Scopes: source.groq, groq-injection.js, groq-injection.markdown
- Samples: blog query, product filter, site navigation
@rexxars rexxars requested a review from a team as a code owner April 13, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant